package com.example.home.adapter.provider

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.entity.BaseEntity
import com.example.home.R
import com.example.home.adapter.DiscoverItemType
import com.example.home.databinding.ItemHomeThemeCardViewBinding
import com.example.home.entity.viewdata.BriefCardViewData

/**
 * 主题卡片
 * */
class ThemeCardProvider : BaseItemProvider<BaseEntity>() {
    override val itemViewType: Int= DiscoverItemType.THEME_CARD_VIEW
    override val layoutId: Int= R.layout.item_home_theme_card_view

    override fun onViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        DataBindingUtil.bind<ItemHomeThemeCardViewBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: BaseEntity) {
        var binding = helper.getBinding<ItemHomeThemeCardViewBinding>()
        if (item!=null && binding!=null){
            var entity= item as BriefCardViewData

            binding.btnAction.setOnClickListener {

            }

            //entity.coverUrl="https://inews.gtimg.com/news_bt/OOZK0thKzk4uiI3gY_d_l8tRI48eUD9fg7r_RZdyUryvEAA/1000"

            binding.viewData=entity
            binding.executePendingBindings()
        }

    }
}